import time


def timer(func):
    """装饰器"""
    def inner(*args, **kwargs):
        start_time = time.time()
        ret = func(*args, **kwargs)
        end_time = time.time()
        print(f"{func.__name__} 运行时间：", end_time - start_time)
        # print(msg)
        return ret

    return inner


@timer("this is another test!")
def test(msg):
    print(msg)

# 等价于：test = timer(test)
# 等价于：test = timer("this is another test!")(test)


if __name__ == '__main__':
    test("this is test!")